<?php

namespace App\Http\Controllers\Plugin;


use App\Helpers\ResponseData;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Intervention\Image\ImageManagerStatic as Image;
use Illuminate\Support\Facades\Storage;
class LocalUploadFileController extends Controller
{
    use ResponseData;
    public function upload(Request $request)
    {
        if ($request->hasFile('file') && $request->file('file')->isValid()) {
            $photo = $request->file('file');
            Storage::makeDirectory('public/goods/video');
            $file_name = uniqid();
            //存储本地
            $photo->storeAs('public/goods/video',$file_name.'.'.$photo->getClientOriginalExtension());
            $img['source'] = 'storage/goods/video/'.$file_name.'.'.$photo->getClientOriginalExtension();
            return $this->success($img);
        }else{
            return response('未上传任何文件');
        }
    }
}
